<script setup lang="ts">
import { ref } from "vue";
const imgRef = ref<HTMLImageElement | null>(null);
//可选链**操作符( **`?.`** )允许读取位于连接对象链深处的属性的值，而不必明确验证链中的每个引用是否有效。
const onMounted = () => {
  console.log(imgRef.value?.innerHTML);
};
</script>

<template>
  <h1 ref="imgRef">我是大部</h1>
  <button @click="onMounted">获取标签</button>
</template>

<style scoped></style>
